package
{
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.MouseEvent;
	import flash.geom.Point;

	public class GMScaffold implements IGameMode
	{
		public var scaffoldDisplay:DisplayObject;
		public function GMScaffold(parentDisplay:DisplayObjectContainer)
		{
			scaffoldDisplay = Scaffold.getDisplay();
			parentDisplay.addChild(scaffoldDisplay);
		}
		
		public function onMouseMove(me:MouseEvent):void{
			var gamePoint:Point = Game.instance.stage2game(new Point(me.stageX, me.stageY));
			var currentPosition:Point = Util.clamp(gamePoint, Game.PPS);
			scaffoldDisplay.x = currentPosition.x;
			scaffoldDisplay.y = currentPosition.y;
		}
		
		public function onMouseUp(me:MouseEvent):void{
			var gamePoint:Point = Game.instance.stage2game(new Point(me.stageX, me.stageY));
			var currentPosition:Point = Util.clamp(gamePoint, Game.PPS);
			
			Game.instance.buyScaffold(currentPosition);
		}
		
		public function onMouseDown(me:MouseEvent):void{
				
		}
		
		public function cleanup():void{
			scaffoldDisplay.visible = false;
			scaffoldDisplay.parent.removeChild(scaffoldDisplay);
		}
	}
}